/* GUI CONVERTED from rcsomtc.p (converter v1.75) Mon Jul  2 09:30:34 2001 */
/* rcsomtc.p - Release Management Customer Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.3.1.3 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.4          CREATED: 01/04/95           BY: rxm **        */
/* REVISION: 7.4    LAST MODIFIED: 01/04/95           BY: rxm *H09P*    */
/* REVISION: 7.4    LAST MODIFIED: 02/23/95           BY: jzw *H0BM*    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*               */
/* $Revision: 1.3.1.3 $    BY: Anil Sudhakaran  DATE: 06/13/01  ECO: *M1B5* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter sod_recid as recid.
define input parameter so_recid as recid.

define variable zone_to             like txz_tax_zone no-undo.
define variable zone_from           like txz_tax_zone no-undo.
define variable tax_usage           like so_tax_usage no-undo.
define variable tax_env             like so_tax_env no-undo.

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
sod_tax_usage   colon 25
   sod_tax_env     colon 25
   sod_tax_in      colon 25
 SKIP(.4)  /*GUI*/
with frame set_tax overlay centered side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-set_tax-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame set_tax = F-set_tax-title.
 RECT-FRAME-LABEL:HIDDEN in frame set_tax = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame set_tax =
  FRAME set_tax:HEIGHT-PIXELS - RECT-FRAME:Y in frame set_tax - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME set_tax = FRAME set_tax:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame set_tax:handle).

find sod_det where recid(sod_det) = sod_recid no-lock.
find so_mstr where recid(so_mstr) = so_recid no-lock.

/* INITIALIZE TEMPORARY NO-UNDO VARS */
tax_usage = sod_tax_usage.
tax_env   = sod_tax_env.

taxloop:
do on error undo, retry:

   sod_tax_usage = tax_usage.
   sod_tax_env   = tax_env.

   /* SUGGEST TAX ENVIRONMENT */
   if sod_tax_env = "" then do:

      /* LOAD DEFAULTS */
      find ad_mstr where ad_addr = so_ship no-lock no-error.
      if available ad_mstr then
      do:
         /* If the address is of list type "dock" then find the
          * Corresponding ship-to or sold-to address to assign the
          * Zone_to field */
         for first ls_mstr where ls_addr = ad_addr and
               (ls_type = "customer" or ls_type = "ship-to" or ls_type = "dock")
               no-lock:
         end.
         if ls_type = "dock" then do:
            for first ls_mstr where ls_addr = ad_ref and
                  (ls_type = "ship-to" or ls_type = "customer")
                  no-lock:
               for first ad_mstr where ad_addr = ls_addr no-lock:
               end.
            end. /* for first ls_mstr.... */
         end. /* if ad_ref <> "" */
         zone_to = ad_tax_zone.
      end. /* if available ad_mstr */

      else do:
         find ad_mstr where ad_addr = so_cust no-lock no-error.
         if available(ad_mstr) then
            zone_to = ad_tax_zone.
      end.

      /* CHECK FOR SITE ADDRESS */
      find ad_mstr where ad_addr = sod_site no-lock no-error.
      if available(ad_mstr) then
         zone_from = ad_tax_zone.
      else do:

         {pxmsg.i &MSGNUM=864 &ERRORLEVEL=2} /* SITE ADDRESS DOES NOT EXIST */
         zone_from = "".
      end.

      {gprun.i ""txtxeget.p"" "(input  zone_to,
                     input  zone_from,
                     input  so_taxc,
                     output sod_tax_env)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   end. /* sod_tax_env = "" */

   update
      sod_tax_usage
      sod_tax_env
      sod_tax_in
   with frame set_tax.

   tax_usage = sod_tax_usage.

   /* VALIDATE TAX ENVIRONMENT */
   /* IF BLANK - SUGGEST AGAIN */
   if sod_tax_env = "" then do:

      {pxmsg.i &MSGNUM=944 &ERRORLEVEL=3}
      /* BLANK TAX ENVIRONMENT NOT ALLOWED */
      tax_env = "".
      next-prompt sod_tax_env with frame set_tax.
      undo taxloop, retry.
   end.

   /* ELSE UNDO TAXLOOP */
   if not {gptxe.v "input sod_tax_env" ""no""} then do:

      {pxmsg.i &MSGNUM=869 &ERRORLEVEL=3} /* TAX ENVIRONMENT DOES NOT EXIST */
      next-prompt sod_tax_env with frame set_tax.
      undo taxloop, retry.
   end.
   hide frame set_tax.
end.
